package Demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-05-18
 * Time: 12:20
 */
public class Test {
    public static void main(String[] args) {
        Animal animal = new Dog("大黄",7);//向上转型
        if(animal instanceof Dog){
            Dog dog = (Dog)animal;
            dog.wangWang();
        }else{

        }


    }
    public void func(Animal animal){
        animal.eat();
    }
    public static void main1(String[] args) {
        Test t = new Test();
        Dog dog = new Dog("大黄",7);
        t.func(dog);
        Bird bird = new Bird("小鸟",2);
        t.func(bird);
    }
}
